import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12

import "pages"

Window {
    id: rootWnd
    visible: true
    width: 1680
    height: 1050
    color: "#3d3a3a"
    flags: Qt.Window | Qt.FramelessWindowHint

    // 自定义标题栏
    TitleBar {
        id: titleBar
        showTxt: "Master-V1.0"
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.right: parent.right
    }

    // 左侧菜单栏
    MenuBar {
        id: menuBar
        anchors.top: parent.top
        anchors.topMargin: 50
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        viewModel: ListModel {
            ListElement { iconImg: "images/14.png"; iconName: "信息"; }
            ListElement { iconImg: "images/9.png"; iconName: "布局"; }
            ListElement { iconImg: "images/10.png"; iconName: "算法"; }
            ListElement { iconImg: "images/11.png"; iconName: "自动化"; }
            ListElement { iconImg: "images/12.png"; iconName: "列表"; }
            ListElement { iconImg: "images/13.png"; iconName: "变换"; }
        }
        onViewIndexChanged: {
            changePage(viewIndex)
        }
    }

    StackView {
        id: mainView
        anchors {
            top: titleBar.bottom
            bottom: parent.bottom
            right: parent.right
            left: menuBar.right
        }
        initialItem: infoPage
    }

    function changePage(indexPage) {
        mainView.clear();
        switch(indexPage) {
        case 0:
            mainView.push(infoPage);
            break;
        case 1:
            mainView.push(layoutPage);
            break;
        case 2:
            mainView.push(algorithmPage);
            break;
        case 3:
            mainView.push(autoPage);
            break;
        case 4:
            mainView.push(listPage);
            break;
        case 5:
            mainView.push(conversionPage);
            break;
        }
    }

    Component { id: infoPage; InfoPage {} }
    Component { id: layoutPage; LayoutPage {} }
    Component { id: listPage; ListPage {} }
    Component { id: conversionPage; ConversionPage {} }
    Component { id: autoPage; AutomationPage {} }
    Component { id: algorithmPage; AlgorithmPage {} }
}
